/*
 * @Author: zhangzhen
 * @Date: 2023-01-06 09:11:46
 * @LastEditors: zhangzhen
 * @LastEditTime: 2023-03-16 10:24:31
 *
 */
import Ids from 'ids';
import {FormConTextValueType} from './context';
import {FormProps} from 'antd';


// 左侧控件数据源
export const buttonList: {
    id: string;
    value: FormConTextValueType;
    name: string;
}[] = [
    {
        id: 'input',
        name: '单文本',
        value: {
            key: 'input',
            name: 'input',
            label: '单文本',
            placeholder: '请输入',
            maxLength: 100,
            infoCome: 0,
            disabled: false,
            required: false,
            isSearch: false,
            isShowInTable: false,
            labelSpan:110,
        },
    },
    {
        id: 'textarea',
        name: '多文本',
        value: {
            key: 'textarea',
            name: 'textarea',
            label: '多文本',
            placeholder: '请输入',
            maxLength: 200,
            labelSpan:110,
            infoCome: 0,
            disabled: false,
            required: false,
            isSearch: false,
            isShowInTable: false,
        },
    },
    {
        id: 'select',
        name: '下拉菜单',
        value: {
            key: 'select',
            name: 'select',
            label: '下拉菜单',
            placeholder: '请输入',
            labelSpan:110,
            disabled: false,
            infoCome: 0,
            required: false,
            isSearch: false,
            isShowInTable: false,
            options: [
                {
                    label: '早',
                    value: '1',
                },
                {
                    label: '中',
                    value: '2',
                },
                {
                    label: '晚',
                    value: '3',
                },
            ],
            allowClear: true,
        },
    },
    {
        id: 'radio',
        name: '单选框',
        value: {
            key: 'radio',
            name: 'radio',
            label: '单选框',
            options: [
                {
                    label: '早',
                    value: '1',
                },
                {
                    label: '中',
                    value: '2',
                },
                {
                    label: '晚',
                    value: '3',
                },
            ],
            labelSpan:110,
            disabled: false,
            required: false,
            isSearch: false,
            isShowInTable: false,
        },
    },
    {
        id: 'checkbox',
        name: '多选框',
        value: {
            key: 'checkbox',
            name: 'checkbox',
            label: '多选框',
            options: [
                {
                    label: '早',
                    value: "1",
                },
                {
                    label: '中',
                    value: "2",
                },
                {
                    label: '晚',
                    value: "3",
                },
            ],
            disabled: false,
            required: false,
            labelSpan:110,
            isSearch: false,
            isShowInTable: false,
        },
    },
    {
        id: 'datePicker',
        name: '日期选择',
        value: {
            key: 'datePicker',
            name: 'datePicker',
            label: '日期选择',
            disabled: false,
            required: false,
            isSearch: false,
            labelSpan:110,
            isShowInTable: false,
        },
    },
    {
        id: 'rangePicker',
        name: '日期范围',
        value: {
            key: 'rangePicker',
            name: 'rangePicker',
            label: '日期范围',
            disabled: false,
            labelSpan:110,
            required: false,
            isSearch: false,
            isShowInTable: false,
        },
    },
    // {
    //     id: 'table',
    //     name: '列表',
    //     value: {
    //         key: 'table',
    //         name: 'table',
    //         label: '列表',
    //         rowKey: 'key',
    //         columns: [],
    //         dataSource: [],
    //         labelSpan:110,
    //         disabled: false,
    //         required: false,
    //         isSearch: false,
    //         isShowInTable: false,
    //     },
    // },
];

export const expendButtonList: {
    id: string;
    value: FormConTextValueType;
    name: string;
}[] = [
    // {
    //     id: 'treeSelect',
    //     name: '组织机构',
    //     value: {
    //         key: 'treeSelect',
    //         name: 'treeSelect',
    //         label: '组织机构',
    //         multiple: false,
    //         placeholder: '请输入',
    //         disabled: false,
    //         required: false,
    //         isSearch: false,
    //         isShowInTable: false,
    //         isMainOrg:false
    //     },
    // },
    // {
    //     id: 'upload',
    //     name: '附件上传',
    //     value: {
    //         key: 'upload',
    //         name: 'upload',
    //         label: '附件上传',
    //         disabled: false,
    //         required: false,
    //         isSearch: false,
    //         isShowInTable: false,
    //         size: '104857600',
    //         sizeText: '100M',
    //         limit: 1,
    //         infoType:
    //             '.png,.jpg,.jpeg,.mp4,.mp3,.doc,.docx,.xls,.xlsx,.ppt,.pps,.ppsx,.pdf,.txt,.zip,.rar',
    //         type: 'attachment',
    //     },
    // },
];

// 拖拽唯一Type
export enum ItemTypes {
    Field = 'field',
}

const ids = new Ids([32, 32, 1]);

export const getId = (key: string): string => key + ids.next();

export type FormDesignType = {
    /**
     * 是否编辑
     */
    isEdit: boolean;
    /**
     * 默认值
     */
    defaultValue?: any[];
     /*
     * 表单默认值
     */
     formDefaultValue?: Record<string, string>;
    /**
     * 默认布局值
     */
    defaultLayout?: any;
    /**
     * 只展示表单项
     */
    onlyShowForm?: boolean;
    /**
     * 只展示表单项
     */
    checkForm?: boolean;
    /**
     * 表单提交方法
     */
    onSubmit?: (values: any) => void;
    ref?: any;
};

export const uploadTypeOptions = [
    {
        label: '附件',
        type: 'attachment',
        value: '.png,.jpg,.jpeg,.mp4,.mp3,.doc,.docx,.xls,.xlsx,.ppt,.pps,.ppsx,.pdf,.txt,.zip,.rar',
        size: '104857600',
        sizeText: '100M',
        limit: 1,
    },
    {
        label: '图片',
        type: 'image',
        value: '.png,.jpg,.jpeg',
        size: '10485760',
        sizeText: '10M',
        limit: 9,
    },
    {
        label: '音视频',
        type: 'video',
        value: '.mp4,.mp3',
        size: '104857600',
        sizeText: '100M',
        limit: '',
    },
    {
        label: '文档',
        type: 'document',
        value: '.doc,.docx,.xls,.xlsx,.ppt,.pps,.ppsx,.pdf,.txt',
        size: '104857600',
        sizeText: '100M',
        limit: '',
    },
    {
        label: '压缩包',
        type: 'zip',
        value: '.zip,.rar',
        size: '104857600',
        sizeText: '100M',
        limit: '',
    },
];

export type LayoutType = {
    layout: FormProps['layout'];
    labelCol: number;
    colSpan: 1 | 2 | 3;
};
